package main

import (
	"fmt"
	"time"
	"strings"
	"net/http"
	"io/ioutil"
)

var PANURL string ="https://pan.baidu.com/share/verify?surl=6M9LKDghZpdwZspiH77l2w"

func GetBaiduURL() string{
	return fmt.Sprintf("%s&t=%d&channel=chunlei&app_id=250528&web=1&clienttype=0", PANURL, time.Now().UnixNano() / 1e6)
}

func HttpPostForm(code string) {
	client := &http.Client{}
	data := url.Values{"pwd": code}
	form = strings.NewReader(data.Encode())
	req, err := http.NewRequest("POST", GetBaiduURL(), form)
	if err != nil {
		panic("error new request")
	}

	req.Header.Set("Host", "pan.baidu.com")
	req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0")
	req.Header.Set("Accpet", "*/*")
	req.Header.Set("Accept-Language", "en-US,en;q=0.5")
	//req.Header.Set("Accept-Encoding", "gzip, deflate, br")
	req.Header.Set("Referer", "https://pan.baidu.com/share/init?surl=6M9LKDghZpdwZspiH77l2w")
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
	req.Header.Set("X-Requested-With", "XMLHttpRequest")
	req.Header.Set("Content-Length", "26")
	req.Header.Set("Connection", "keep-alive")

	req.Form()

	resp, err := client.Do(req)
	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		panic("err ready body")
	}
	fmt.Println(string(body))
}


func main(){
	HttpPostForm()
}
